package com.spring.lth.server.impl;

import com.spring.lth.domain.Card;
import com.spring.lth.mapper.CardMapper;
import com.spring.lth.server.ICardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 罗天豪
 * @date 2019/7/26
 */
@Service
public class ICardServiceImpl implements ICardService {

    @Autowired
    private CardMapper mapper;
    @Override
    public Card getCardById(Long id) {
        Card card = mapper.selectCardById(id);
        return card;
    }

    @Override
    public Card saveCard(Card card) {
        int i = mapper.insertCard(card);
        if (i==1){
            Card card1 = new Card();
            card1.setCId(card.getCId());
            card1.setCCode(card.getCCode());
            return card1;
        }
        return null;
    }

    @Override
    public Card removeCard(Card card) {
        int i = mapper.deleteCardById(card);
        if (i==1) {
            return card;
        }
        return null;
    }
}
